package com.shop.servlet.utils;

import com.shop.servlet.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class UserSecurity {
    public static Long getUserId(){
        LoginUser userDetails =  (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return userDetails.getId();
    }
}
